package cn.y.operation.framework.enums;

import java.util.HashMap;
import java.util.Map;

public enum ContentTypeEnum {

    JPE(".jpe", "image/jpeg"),
    JPEG(".jpeg", "image/jpeg"),
    JPG(".jpg", "image/jpg"),
    BMP(".bmp", "image/bmp"),
    PNG(".png", "image/png"),
    GIF(".gif", "image/gif"),
    MP3(".mp3", "audio/mp3"),
    TXT(".txt", "text/plain"),
    WMV(".wmv", "video/x-ms-wmv"),
    MP4(".mp4", "video/mpeg4"),
    AVI(".avi", "video/avi"),
    XML(".xml", "application/xml"),
    JSON(".json", "application/json"),
    UNKNOWN(".*", "application/octet-stream");;
    private final String value;
    private final String displayName;
    private static final Map<String, ContentTypeEnum> dataMap = new HashMap<>();

    static {
        for (ContentTypeEnum ut : values()) {
            dataMap.put(ut.getValue(), ut);
        }
    }

    private ContentTypeEnum(String value, String displayName) {
        this.value = value;
        this.displayName = displayName;
    }

    public String getValue() {
        return this.value;
    }

    public String getDisplayName() {
        return this.displayName;
    }

    public static String getDisplayName(String value) {
        return dataMap.get(value).getDisplayName();
    }

    public static ContentTypeEnum getEnum(String value) {
        return dataMap.get(value);
    }
}
